package com.vital.mshopping;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;

public class ImageViewActivity extends Activity {
	GridView gridViewImage;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_image_view);
		
		gridViewImage = (GridView)findViewById(R.id.gridImage);
		gridViewImage.setAdapter(new ImageAdapter(this));
		gridViewImage.setOnItemClickListener(image_click);
	}
	
	private OnItemClickListener image_click = new OnItemClickListener() {

		public void onItemClick(AdapterView<?> parent, View view, int position,
				long id) {
			// TODO Auto-generated method stub
			//---Send image id to back Add Category view---
			Intent intent = new Intent();
			
			//---Set the data to pass back---
			intent.putExtra("posImage", position);
			setResult(RESULT_OK, intent);
			
			//---Close activity---
			finish();
		}
	};
}
